class RequestAndComplaint::ComplaintTypesController < ApplicationController
  # GET /request_and_complaint/complaint_types
  # GET /request_and_complaint/complaint_types.xml
  def index
    @title_view = 'Tipo de Denuncias'
    @request_and_complaint_complaint_types = RequestAndComplaint::ComplaintType.all

    respond_to do |format|
      format.html # index.html.erb
      format.xml  { render :xml => @request_and_complaint_complaint_types }
    end
  end

  # GET /request_and_complaint/complaint_types/1
  # GET /request_and_complaint/complaint_types/1.xml
  def show
    @title_view = 'Tipo de Denuncias'
    @request_and_complaint_complaint_type = RequestAndComplaint::ComplaintType.find(params[:id])

    respond_to do |format|
      format.html # show.html.erb
      format.xml  { render :xml => @request_and_complaint_complaint_type }
    end
  end

  # GET /request_and_complaint/complaint_types/new
  # GET /request_and_complaint/complaint_types/new.xml
  def new
    @title_view = 'Tipo de Denuncias'
    @request_and_complaint_complaint_type = RequestAndComplaint::ComplaintType.new

    respond_to do |format|
      format.html # new.html.erb
      format.xml  { render :xml => @request_and_complaint_complaint_type }
    end
  end

  # GET /request_and_complaint/complaint_types/1/edit
  def edit
    @title_view = 'Tipo de Denuncias'
    @request_and_complaint_complaint_type = RequestAndComplaint::ComplaintType.find(params[:id])
  end

  # POST /request_and_complaint/complaint_types
  # POST /request_and_complaint/complaint_types.xml
  def create
    @title_view = 'Tipo de Denuncias'
    @request_and_complaint_complaint_type = RequestAndComplaint::ComplaintType.new(params[:request_and_complaint_complaint_type])

    respond_to do |format|
      if @request_and_complaint_complaint_type.save
        format.html { redirect_to(@request_and_complaint_complaint_type, :notice => 'Complaint type was successfully created.') }
        format.xml  { render :xml => @request_and_complaint_complaint_type, :status => :created, :location => @request_and_complaint_complaint_type }
      else
        format.html { render :action => "new" }
        format.xml  { render :xml => @request_and_complaint_complaint_type.errors, :status => :unprocessable_entity }
      end
    end
  end

  # PUT /request_and_complaint/complaint_types/1
  # PUT /request_and_complaint/complaint_types/1.xml
  def update
    @title_view = 'Tipo de Denuncias'
    @request_and_complaint_complaint_type = RequestAndComplaint::ComplaintType.find(params[:id])

    respond_to do |format|
      if @request_and_complaint_complaint_type.update_attributes(params[:request_and_complaint_complaint_type])
        format.html { redirect_to(@request_and_complaint_complaint_type, :notice => 'Complaint type was successfully updated.') }
        format.xml  { head :ok }
      else
        format.html { render :action => "edit" }
        format.xml  { render :xml => @request_and_complaint_complaint_type.errors, :status => :unprocessable_entity }
      end
    end
  end

  # DELETE /request_and_complaint/complaint_types/1
  # DELETE /request_and_complaint/complaint_types/1.xml
  def destroy
    @request_and_complaint_complaint_type = RequestAndComplaint::ComplaintType.find(params[:id])
    mensaje = @request_and_complaint_complaint_type.erasable
    if mensaje.blank?
      @request_and_complaint_complaint_type.deleted = 1
      @request_and_complaint_complaint_type.save
    end
    respond_to do |format|
      format.html { redirect_to(request_and_complaint_complaint_types_url, :notice => mensaje) }
      format.xml  { head :ok }
    end
  end
end
